package com.yanqu.road.logic.model.cricket;

import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.cricket.CricketProto;

public class CricketUserBaseInfo {
    public static CricketUserBaseInfo getInstance(CricketProto.CricketUserBattleDataTemp cricketUserBattleDataTemp) {
        return new CricketUserBaseInfo(cricketUserBattleDataTemp);
    }

    public CricketUserBaseInfo() {

    }

    private CricketUserBaseInfo(CricketProto.CricketUserBattleDataTemp cricketUserBattleDataTemp) {
        userId = cricketUserBattleDataTemp.getUserId();
        userBaseInfo = PlayerBasePb.parseToUserBaseInfo(cricketUserBattleDataTemp.getPlayerBaseData());
        score = cricketUserBattleDataTemp.getScore();
        courtBadgeId = cricketUserBattleDataTemp.getCourtBadgeId();
    }

    public CricketProto.CricketUserBattleDataTemp toProtobuf() {
        if (userId == 0 || userBaseInfo == null) {
            return null;
        }
        CricketProto.CricketUserBattleDataTemp.Builder builder = CricketProto.CricketUserBattleDataTemp.newBuilder();
        builder.setUserId(userId);
        builder.setPlayerBaseData(PlayerBasePb.parsePlayerBaseTempMsg(userBaseInfo));
        builder.setScore(score);
        builder.setCourtBadgeId(courtBadgeId);
        return builder.build();
    }

    private long userId;
    private com.yanqu.road.entity.player.UserBaseInfo userBaseInfo;
    private long score;
    private int courtBadgeId;

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public com.yanqu.road.entity.player.UserBaseInfo getUserBaseInfo() {
        return userBaseInfo;
    }

    public void setUserBaseInfo(com.yanqu.road.entity.player.UserBaseInfo userBaseInfo) {
        this.userBaseInfo = userBaseInfo;
    }

    public long getScore() {
        return score;
    }

    public void setScore(long score) {
        this.score = score;
    }

    public int getCourtBadgeId() {
        return courtBadgeId;
    }

    public void setCourtBadgeId(int courtBadgeId) {
        this.courtBadgeId = courtBadgeId;
    }
}
